﻿namespace CN2P.ServiceModel
{
    using System.Collections.Generic;
    using System.Linq;
    using System.Runtime.Serialization;

    [DataContract]
    public class OrderModel
    {
        public OrderModel()
        {
            this.Items = new List<OrderItemModel>();
        }

        [DataMember(Name = "orderId")]
        public string OrderId { get; set; }

        [DataMember(Name = "userId")]
        public string UserId { get; set; }

        [DataMember(Name = "totalValue")]
        public decimal TotalValue { get; set; }

        [DataMember(Name = "orderDate")]
        public string OrderDate { get; set; }

        [DataMember(Name = "items")]
        public IList<OrderItemModel> Items { get; set; }

        public bool HasProduct(string productId)
        {
            return this.Items.Any(item => item.ProdId == productId);
        }
    }
}
